//
// Created by luolijun on 2021/11/9.
//
#include "FalconDocument.h"

namespace falcon {

FalconDocument::FalconDocument() {
    project = new Project;
    facadeRepo = falcon::CreateFacadeRepo();
    pendingFacade = nullptr;
}

FalconDocument::~FalconDocument() {
}

int FalconDocument::open(const QString& filename) {
    Q_ASSERT(project != nullptr);

    //  从文件加载工程
    int ret = LoadProject(filename.toStdString(), project);
    if (ret != 0) {
        Q_ASSERT(false);
        return ret;
    }

    //  创建 facade 仓库
    facadeRepo = falcon::CreateFacadeRepo();
    Q_ASSERT(facadeRepo != nullptr);
    ret = falcon::LoadBuiltinPrototypes(facadeRepo);
    if (ret != 0) {
        Q_ASSERT(false);
        return ret;
    }

    return 0;
}

int FalconDocument::save(const QString& filename) {
    return 0;
}

int FalconDocument::saveAs(const QString& filename) {
    return 0;
}

void FalconDocument::close() {
}

} // namespace falcon